import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { Switch, Route } from 'react-router-dom';
import { connect } from 'react-redux'

import Auth from './Auth';
import PrivateRoute from './PrivateRoute';
import CustomHome from './CustomHome';

class Layout extends PureComponent {
    constructor(props) {
        super(props)
    }
    
    render() {
        const { logged } = this.props;
        return (
            <Switch>
                <Route path="/auth" component={Auth} />
                <PrivateRoute isAuthenticated={logged} component={CustomHome} />
            </Switch>
        )
    }
}

const mapStateToProps = state => ({
    logged: state.user.logged
})

export default connect(mapStateToProps)(Layout)
